<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								用户编号：<input type="text" name="merchantId"/>
							</li>
							<li>
								用户手机：<input type="text" name="merchantPhone"/>
							</li>
						<!-- 	<li>
								银行名称：<input type="text" name="bankName"/>
							</li>

							<li>
								银行账户：<input type="text" name="bankAccount"/>
							</li> -->

							<!-- <li>
								银行账户名称：<input type="text" name="bankAccountName"/>
							</li>

							<li>
								身份证号：<input type="text" name="idCardNumber"/>
							</li>

							<li>
								创建时间：<input type="text" name="createTime"/>
							</li>

							<li>
								提交验证时间：<input type="text" name="submitExamineTime"/>
							</li>

							<li>
								验证通过时间：<input type="text" name="examinePassTime"/>
							</li>

							<li>
								审核记录：<input type="text" name="auditRecord"/>
							</li>

							<li>
								验证结构：<input type="text" name="examineResult"/>
							</li>

							<li>
								状态：<input type="text" name="sTATUS"/>
							</li>

							<li>
								提额审核状态：<input type="text" name="increaseLimitStatus"/>
							</li>

							<li>
								银行预留手机号：<input type="text" name="bankPhone"/>
							</li>

							<li>
								银行卡背面后三位：<input type="text" name="cvn"/>
							</li>

							<li>
								银行卡到期日期：<input type="text" name="expdate"/>
							</li>

							<li>
								最高限额：<input type="text" name="limitMoney"/>
							</li>
 -->
							<li>
								<a id="btnSearch" class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:hatchetMerchantIncreaseLimit:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:hatchetMerchantIncreaseLimit:remove')}]];
        var prefix = ctx + "system/hatchetMerchantIncreaseLimitForJLR";
       // 一进来查询账单日为当天的卡
    	var mydate = new Date();
    	var today = mydate.getDate(); //获取当前日(1-31)
        var tableUrl = prefix + "/list";
        $(function() {
            var options = {
                url: prefix + "/list?billDay="+today,
                updateUrl: prefix + "/edit/{id}",
                modalName: "信用卡",
				search: false,
		        showExport: false,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'iD', 
					title : '主键id',
					visible: false
				},
				{
					field : 'merchantId', 
					title : '用户编号',
					sortable: false
				},
				{
					field : 'merchantName', 
					title : '用户名称',
					sortable: false
				},
				{
					field : 'merchantPhone', 
					title : '手机号码',
					sortable: false
				},
				{
					field : 'bankName', 
					title : '银行名称',
					sortable: false
				},
				{
					field : 'bankAccount', 
					title : '银行卡号',
					sortable: false
				},
				{
					field : 'bankPhone', 
					title : '预留手机号',
					sortable: false
				},
				/* {
					field : 'idCardNumber', 
					title : '身份证号',
					sortable: false
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: false
				},
				{
					field : 'submitExamineTime', 
					title : '提交验证时间',
					sortable: false
				},
				{
					field : 'examinePassTime', 
					title : '验证通过时间',
					sortable: false
				},
				{
					field : 'auditRecord', 
					title : '审核记录',
					sortable: false
				},
				{
					field : 'examineResult', 
					title : '验证结构',
					sortable: false
				},
				{
					field : 'sTATUS', 
					title : '状态',
					sortable: false
				},
				{
					field : 'increaseLimitStatus', 
					title : '提额审核状态',
					sortable: false
				},
				{
					field : 'bankPhone', 
					title : '银行预留手机号',
					sortable: false
				},
				{
					field : 'cvn', 
					title : '银行卡背面后三位',
					sortable: false
				},
				{
					field : 'expdate', 
					title : '银行卡到期日期',
					sortable: false
				}, */
				/* {
					field : 'limitMoney', 
					title : '最高限额',
					sortable: false
				}, */
				{
					field : 'billDay', 
					title : '出账单日',
					sortable: true
				},
				{
					field : 'repaymentDay', 
					title : '还款日',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	//如果经理人托管该卡并且如果该卡没有执行中和待执行的计划才 可以制定计划
		            	if(row.entrustStatus=="10B" && row.cvn !="N"){
			            	//跳转制定计划页面
			            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="toAddPlanPage(\'' + row.id + '\')">制定计划</a> ');
						//申请中	 
		            	}else if(row.entrustStatus=="10A") {
		            		actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="accept(\'' + row.id + '\')">接受委托</a> ');
		            		actions.push('<a class="btn btn-danger btn-xs ' + editFlag + '" href="#" onclick="refuse(\'' + row.id + '\')">拒绝委托</a> ');
		            	}
		            	return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        
        function toAddPlanPage(id){
        	$.modal.confirm("您是否从持卡人那清楚知晓该卡的还款金额、周转金(剩余额度)、账单日、还款日?", function() {
        		window.location.href=ctx+'system/hatchetPlanForDLS/addPalnByJLR/'+id;
        	})
        }
        
        //接受委托
        function accept(id){
        	$.modal.confirm("您确定愿意为该卡制定计划?", function() {
        		$.ajax({
    				url : prefix + "/doEntrust",
    				type : "POST",
    				data: {
    					"iD":id,
    					"entrustStatus":"10B"
    					
    				},
    				success : function(re) {
    					if (re.status == "SUCCESS") {
    						$.modal.msgSuccess(re.msg);
    						$("#btnSearch").click();
    					} else {
    						$.modal.msgError(re.msg);
    					}
    				}
    			});
        	})
        	
        }
        //拒绝委托
        function refuse(id){
        	$.ajax({
				url : prefix + "/doEntrust",
				type : "POST",
				data: {
					"iD":id,
					"entrustStatus":"10C"
				},
				success : function(re) {
					if (re.status == "SUCCESS") {
						$.modal.msgSuccess(re.msg);
						$("#btnSearch").click();
					} else {
						$.modal.msgError(re.msg);
					}
				}
			});
        	
        }
        
        
    </script>
</body>
</html>